//引入eventbus
import PubSub from 'pubsub-js'
Component({
    data: {
        name: '',
    },
    lifetimes: {
        attached() {
            //坚挺组件1发送的信息
            //k=事件名称，v=传递的值
            PubSub.subscribe('msgEvent', (k, v) => {
                console.log("k=", k, 'v=', v);
                this.setData({
                    name:v
                })
            })
            //监听父组件发送的信息
            PubSub.subscribe('msgEvent2', (k, v) => {
                console.log("k=", k, 'v=', v);
                this.setData({
                    name:v.name
                })
            })
        }
    }
})